<template>
  <div ref="target" class="modal-container pop-in" :style="{
    top: `${pos.top}px`,
    left: `${pos.left}px`,
    display: visible ? 'block' : 'none'
  }">
    <img class="close-icon" src="@/assets/modal-close.png" alt="" />
    <!-- 插槽位置 -->
    <div class="title">
      {{ title }}
    </div>
    <div class="info">
      <slot />
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  title: {
    title: {
      type: String
    }
  },
  // 位置
  pos: {
    type: Object,
    default: () => ({ left: 0, top: 0 })
  },
  // 是否显示
  visible: {
    type: Boolean,
    default: false
  }
})

</script>

<style scoped lang="scss">
.modal-container {
  position: absolute;
  background: url('@/assets/modal-bg.png') no-repeat 0 0 / cover;
  width: 300px;
  padding: 8px 10px 0;
}

.close-icon {
  width: 20px;
  height: 20px;
  position: absolute;
  top: 6px;
  right: 6px;
  cursor: pointer;
}

.extra {
  position: absolute;
  right: 12px;
  top: 42px;
  background: rgba(10, 26, 52, 0.6);
  border: 1px solid rgba(54, 135, 255, 0.7);
  border-radius: 1px;
  box-shadow: 0px 0px 5px 0.5px rgba(3, 251, 255, 0.65) inset;
  padding: 4px 12px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

.title {
  font-size: 16px;
  font-weight: 500;
  color: #ffffff;
  margin-bottom: 12px;
}

.info {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.info-line {
  margin-bottom: 10px;
}

.pop-in {
  -webkit-animation: fadeleftIn 0.4s;
  animation: fadeleftIn 0.4s;
  -webkit-animation-name: popIn;
  animation-name: popIn;
}

@keyframes popIn {
  0% {
    -webkit-transform: scale3d(0, 0, 0);
    transform: scale3d(0.5, 0.5, 0.5);
    opacity: 0;
  }

  50% {
    -webkit-animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
    animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
  }

  100% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
    -webkit-animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 1;
  }
}
</style>
